from django.contrib.auth.models import AbstractUser
from django.db import models


class Role(models.Model):
    role_id = models.CharField(primary_key=True, max_length=32)
    name = models.CharField(max_length=20, blank=True, null=True)
    class Meta:
        managed = False
        db_table = 'role'


class Staff(AbstractUser):
    staff_id = models.CharField(primary_key=True, max_length=32, verbose_name='职员编号')
    num = models.CharField(max_length=10, verbose_name='编号', blank=True, null=True)
    name = models.CharField(max_length=20, verbose_name='姓名', blank=True, null=True)
    head = models.CharField(max_length=200, verbose_name='用户头像', blank=True, null=True)
    age = models.CharField(max_length=20, verbose_name='年龄', blank=True, null=True)
    phone = models.CharField(max_length=11, verbose_name='电话号码', blank=True, null=True)
    password = models.CharField(max_length=50, verbose_name='密码', blank=True,null=True)
    sex = models.CharField(max_length=10, verbose_name='性别', blank=True, null=True)
    address = models.CharField(max_length=50, verbose_name='家庭地址', blank=True, null=True)
    role = models.ForeignKey(Role, on_delete=models.DO_NOTHING, blank=True, null=True, db_column='role_id', verbose_name='角色编号')

    class Meta:
        db_table = 'staff'
        verbose_name_plural = verbose_name = '用户'

    def __str__(self):
        return f'职员{self.name}'


class Inform(models.Model):
    inform_id = models.CharField(primary_key=True, max_length=32)
    num = models.CharField(max_length=10, blank=True, null=True)
    staff_name = models.CharField(max_length=20, blank=True, null=True)
    staff_num = models.CharField(max_length=10, blank=True, null=True)
    time = models.DateTimeField(blank=True, null=True)
    event = models.CharField(max_length=200, blank=True, null=True)
    status = models.CharField(max_length=10, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'inform'